import _ from 'lodash';

export default {
    isService(data) {
        return _.get(data, 'type') === 'service'
    },
    isModule(data) {
        return _.get(data, 'type') === 'module'
    },
    isModuleForm(data) {
        return this.isModule(data) && (data.svc_module_type == 1 || !data.svc_module_type);
    },
    isModuleApi(data) {
        return this.isModule(data) && data.svc_module_type == 2;
    },
    isApi(data) {
        return _.get(data, 'type') === 'api'
    },
    isPlatform(data) {
        return data && data.id === -100;
    },
    isGlobal(data) {
        return data && data.id === -1;
    },
    isApp(data) {
        return data && (data.isApp || data.nodeType === 'app');
    },
    isRootMenu(data) {
        return this.isApp(data) || this.isGlobal(data) || this.isPlatform(data);
    },
    canEdit(data) {
        let editing = true;

        if(!data || data.project_id === -1 || data.id === -100) {
            editing = false;
        }

        return editing;
    }
}
